﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

namespace PWEditor
{
    class Grid : Panel
    {
        private int _rows = 0;
        private int _cols = 0;
        private int _totalTiles = 0;
        private int _tileSize = 20;
        private Pen _pen;
        private Map _map;

        public Grid(int tileSize, Color gridColor)
        { 
            _tileSize = tileSize;
            _pen = new Pen(gridColor);
        }

        public void Create(Map map)
        {
            _map = map;
            _rows = map.Rows;
            _cols = map.Cols;
            _totalTiles = map.Rows * map.Cols;
        }

        protected override void OnPaint(PaintEventArgs e) 
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;
            for (int i = 0; i <= _rows; i++)
            {
                g.DrawLine(_pen, 0, i * _tileSize, _cols * _tileSize, i * _tileSize);
            }
            for (int i = 0; i <= _cols; i++)
            {
                g.DrawLine(_pen, i * _tileSize, 0, i * _tileSize, _rows * _tileSize);
            }
         }
    }
}
